package org.feng.service.impl;

import org.feng.entity.pojo.Generate;
import org.feng.mapper.GenerateMapper;
import org.feng.service.GenerateService;
import lombok.AllArgsConstructor;
import org.feng.serive.impl.BaseServiceImplNoExtendsImpl;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * <p>
 * 自动生成代码 服务实现类
 * </p>
 *
 * @author feng
 * @since 2020-12-10
 */
@Service
@AllArgsConstructor
public class GenerateServiceImpl extends BaseServiceImplNoExtendsImpl<GenerateMapper, Generate> implements GenerateService {

    private final GenerateMapper generateMapper;
    private final GenerateAuto generateAuto;

    @Override
    public void create(String ids) {
        List<String> list = Arrays.asList(ids.indexOf(",") > 0 ? ids.split(",") : new String[]{ids});
        List<Generate> generates = generateMapper.selectBatchIds(list);
        for (Generate generate : generates) {
            generateAuto.execute(generate);
        }
    }

}
